<template>
    <div style="display:flex;flex-direction:column;height:100vh ">
      <div :style="{backgroundRepeat:'no-repeat',backgroundPosition: 'center center',backgroundSize: 'cover',backgroundImage:sstyle.backgroundImage,flex:1}">
        <el-row style="background: #rgb(32 68 161); text-align:center;color:white;">
        <h1 style="margin-top:50px;text-align:'center'">{{title}}</h1>
      </el-row>
      <el-row>
        <el-col style="margin-top: 50px;text-align:center">
          <el-button @click="languageAuto('cn')"
                     style="height:40px;width:100px;font-weight:bold; background-color:#31c8c8;color:#fff;">中文
          </el-button>
          <el-button @click="languageAuto('en')"
                     style="width:100px;height:40px;margin-left:30px;font-weight:bold; background-color:#31c8c8;color:#fff;">ENGLISH
          </el-button>
        </el-col>
      </el-row>
      <el-row style="margin-top:30%;">
      </el-row>
      </div>
    </div>

</template>

<script>
export default {
  name: "Index",
  components: {},
  data() {
    return {
      url:null,
      version:"6000",
      title:"",
      sstyle:
        {
          backgroundImage: null,
        }
    }
  },
  mounted() {
  },
 async created(){
   let res= await this.getConfigKey("sys.server.version")
   this.version =res.msg||this.version;
   try{
    this.url=require('@/assets/images/'+this.version+'_backg.jpg')
   }catch(e){
      this.url="";
   }

    this.sstyle.backgroundImage='url(' +this.url+ ')'
   let  rs =  await this.getDicts("server_list");
   let serverList = rs.data ||[]
   let dicL=  serverList.find(item=>{
      return   this.version ==item.dictLabel
    })
    if(undefined!=dicL){
        this.title=dicL.dictValue
    }
  },
  methods: {
    // 翻译
    languageAuto(lan) {
      // lan == 'zh' ? (this.language = 'en') : (this.language = 'zh')
      // localStorage.setItem('language', `{"language":"${this.language}"}`)
      if (lan == 'cn') {
        this.$translate.changeLanguage('chinese_simplified')
      }
      if (lan == 'en') {
        console.log('转为英文')
        this.$translate.changeLanguage('english')
      }
      this.$translate.execute() //进行翻译
    }
  },
};
</script>

<style scoped>
*{
  padding:0;
  margin:0;
}
.bgimg
{
          backgroundRepeat: no-repeat;
          backgroundSize: cover;
          backgroundPosition: center center;
          /* minHeight:'100vh' */
}
</style>
